package com.uek.handler;

import com.uek.pojo.BackgroundUser;
import com.uek.service.Impl.BackUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;



@Controller
public class BackUserController {
    @Autowired
    BackUserServiceImpl backUserService;
    @RequestMapping(value = "adminlogin",method = RequestMethod.POST)
    //封装一个对象里面,封装前台页面传过来的数据
    @ResponseBody
    public Result userLogin(@RequestBody BackgroundUser backgroundUser){
        if(StringUtil.isEmpty(backgroundUser.getUsername())||StringUtil.isEmpty(backgroundUser.getPassword())){
            //没有数据返回
            return  Result.failure(ApiCode.ERROR.getCode(), "密码错误");
        }else{
            //请求service
            return backUserService.userLogin(backgroundUser.getUsername(),backgroundUser.getPassword());
        }
    }

}
